# coding:utf8
# log
import logging
from logging.handlers import TimedRotatingFileHandler

logger = logging.getLogger('ay')
logger.setLevel(logging.INFO)
ch = TimedRotatingFileHandler("ay-record.log", when='D', encoding="utf-8")
ch.setLevel(logging.DEBUG)
formatter = logging.Formatter('%(asctime)s - %(name)s - %(levelname)s - %(message)s')
ch.setFormatter(formatter)
logger.addHandler(ch)


class log(object):

    def d(*args):
        print("--------------------------------------")
        print("| - debug:  ", args)
        print("--------------------------------------")
        logger.debug(args)

    def i(*args):
        print("--------------------------------------")
        print("| - info:  ", args)
        print("--------------------------------------")

        logger.info(args)

    def w(*args):
        print("--------------------------------------")
        print("| - warning:  ", args)
        print("--------------------------------------")
        logger.warning(args)

    def e(*args):
        print("--------------------------------------")
        print("| - error:  ", args)
        print("--------------------------------------")
        logger.error(args)

    def c(*args):
        print("--------------------------------------")
        print("| - critical:  ", args)
        print("--------------------------------------")
        logger.critical(args)


# if __name__ == '__main__':
#     log.d("========", "-------", "========")
#     log.i("========", "-------", "========")
#     log.w("========", "-------", "========")
#     log.e("========", "-------", "========")
#     log.c("========", "-------", "========")
